package com.example.bank.shiro.token;

import com.example.bank.util.JWTUtil;
import org.apache.shiro.authc.AuthenticationToken;

/**
 * @author ：Leeziqiang
 * @description：AuthenticationToken接口的实现类，
 * 目的是封装成UsernamePasswordToken让shiro进行登录，登出操作
 * @date ：2021/11/22 14:22
 */
public class JWTToken  implements AuthenticationToken {

    private static final long serialVersionUID = 1L;

    // 加密后的JWTToken
    private String token;
    private String id;

    public JWTToken(String token) {
        this.token = token;
        this.id = JWTUtil.getClaimFiled(token, "id");
    }


    @Override
    public Object getPrincipal() {
        return this.id;
    }

    @Override
    public Object getCredentials() {
        return token;
    }
}
